﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brain;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Demos
{
    public class FarseerSample : DemoScreen
    {
        public Camera2D Camera;

        public Sprite Ground;

        public FarseerSample()
        {
            Camera = new Camera2D(this);
            Engine.Instance.CameraManager.Camera2D = Camera;
            Camera.Draw();

            Ground = new Sprite();
            this.AddComponent(Ground);
            Ground.BoundsRectangle = new Rectangle(400, 400, 500, 100);
            Ground.Physics = SpritePhysics.Rectangle;
            Ground.Rendering = SpriteRendering.Rendered;
            Ground.BoundsRectangleColor = Color.Green;

            Sprite box = new Sprite();
            this.AddComponent(box);
            box.BoundsRectangle = new Rectangle(400, 0, 100, 100);
            box.BoundsRectangleColor = Color.Red;
            box.Rendering = SpriteRendering.Rendered;
            box.Physics = SpritePhysics.Rectangle;
            box.PhysicsObject.Immovable = false;
        }

        public override void Update()
        {
            base.Update();

            float Speed = 5;
            if (Engine.Instance.InputManager.IsKeyDown(Keys.W) ||
                Engine.Instance.InputManager.IsAnyPlayerButtonDown(Buttons.LeftThumbstickUp))
            {
                Camera.Position += new Vector2(0, Speed);
            }
            if (Engine.Instance.InputManager.IsKeyDown(Keys.S) ||
                Engine.Instance.InputManager.IsAnyPlayerButtonDown(Buttons.LeftThumbstickDown))
            {
                Camera.Position -= new Vector2(0, Speed);
            }
            if (Engine.Instance.InputManager.IsKeyDown(Keys.A) ||
                Engine.Instance.InputManager.IsAnyPlayerButtonDown(Buttons.LeftThumbstickLeft))
            {
                Camera.Position += new Vector2(Speed, 0);
            }
            if (Engine.Instance.InputManager.IsKeyDown(Keys.D) ||
                Engine.Instance.InputManager.IsAnyPlayerButtonDown(Buttons.LeftThumbstickRight))
            {
                Camera.Position -= new Vector2(Speed, 0);
            }

            float mouse = Engine.Instance.InputManager.GetMouseWheelDifference();
            if (mouse > 0)
            {
                mouse = 1;
            }
            if (mouse < 0)
            {
                mouse = -1;
            }
            Camera.Zoom += mouse / 100f;
        }

    }
}
